home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / dev / gcc / libnixV0_8.lha / gnu / libnix-sources.lha / sources / nix / extra / getcwd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-17  |  371 b   |  23 lines

  1. #include <stdlib.h>
  2. #include <errno.h>
  3. #include <unistd.h>
  4. #ifdef __GNUC__
  5. #include <inline/dos.h>
  6. #endif
  7.  
  8. extern void __seterrno();
  9.  
  10. char *getcwd(char *buf,size_t size)
  11. {
  12.   if (buf!=NULL || (buf=(char *)malloc(size))!=NULL)
  13.   {
  14.     if (GetCurrentDirName(buf,(ULONG)size)==DOSFALSE)
  15.     {
  16.        __seterrno(); buf=NULL;
  17.     }
  18.   }
  19.   else
  20.     errno=ENOMEM;
  21.   return buf;
  22. }
  23.